package com.hsm4;

public class Student implements Comparable<Student>{
    private int age;
    private String name;
    private double height;

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public double getHeight() {
        return height;
    }

    public void setHeight(double height) {
        this.height = height;
    }

    public Student(int age, String name, double height) {
        this.age = age;
        this.name = name;
        this.height = height;
    }

    @Override
    public String toString() {
        return "Student{" +
                "age=" + age +
                ", name='" + name + '\'' +
                ", height=" + height +
                '}';
    }


    @Override
    //如果想比较两个学生的年龄、身高、名字
    public int compareTo(Student o) {
        /*年龄：
        return this.age-o.age;
        */
        /*身高：
        return ((Double)(this.getHeight())).compareTo((Double) (o.getHeight()));
        */
        //名字
        return (this.getName()).compareTo((o.getName()));

    }
}
